/*********************************************************************************
 * 
 * Author: wujunjie
 * Create Date: 2014-05-10
 * Description:
 *          
 * Revision History:
 *      Date          Author               Description
 * 
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataFrameworkAccess;
using Xinkui.Entity.AutoGenerator;
using Xinkui.Common;
namespace Xinkui.DataAccess.AutoGenerator {
    public partial class ProductInfoDataAccess
    {
        public List<ProductInfo_Entity> ProductInfo_ListByPaging(int pageSize, int pageIndex,out int total)
        {
			total= 0;
            try
            {
				int tempRecord = 0;
                DataCommand cmd = DataCommandManager.GetDataCommand("ProductInfo_ListByPaging");
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@PageIndex", pageIndex);
				cmd.SetParameterValue("@RecordCount", tempRecord);
                List<ProductInfo_Entity> pageList = cmd.ExecuteEntityList<ProductInfo_Entity>();
                total = Convert.ToInt32(cmd.GetParameterValue("@RecordCount"));
				return pageList;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<ProductInfo_Entity>(0);

        }

        public ProductInfo_Entity ProductInfo_View(System.Int32 ProductID)
        {
            ProductInfo_Entity c = default(ProductInfo_Entity);
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("ProductInfo_View");
                cmd.SetParameterValue("@ProductID", ProductID);
                c = cmd.ExecuteEntity<ProductInfo_Entity>();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return c;
        }

        public ProductInfo_Entity ProductInfo_Add(ProductInfo_Entity entity)
        {
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("ProductInfo_Add");
                cmd.SetParameterValue("@ProductID", entity.ProductID);
                cmd.SetParameterValue("@ProductName", entity.ProductName);
                cmd.SetParameterValue("@CategoryID", entity.CategoryID);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@UserID", entity.UserID);
                cmd.SetParameterValue("@ProductDescription", entity.ProductDescription);
                cmd.SetParameterValue("@PlaceOfOrigin", entity.PlaceOfOrigin);
                cmd.SetParameterValue("@MainKeyword", entity.MainKeyword);
                cmd.SetParameterValue("@Keywords", entity.Keywords);
                cmd.SetParameterValue("@OEMNO", entity.OEMNO);
                cmd.SetParameterValue("@CertificateIDS", entity.CertificateIDS);
                cmd.SetParameterValue("@GroupID", entity.GroupID);
                cmd.SetParameterValue("@KeyProducts", entity.KeyProducts);
                cmd.SetParameterValue("@Application", entity.Application);
                cmd.SetParameterValue("@PicImgs", entity.PicImgs);
                cmd.SetParameterValue("@IsDeleted", entity.IsDeleted);
                cmd.SetParameterValue("@CreateDate", entity.CreateDate);
                cmd.SetParameterValue("@CreateIP", entity.CreateIP);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.SetParameterValue("@UpdateIP", entity.UpdateIP);
                cmd.SetParameterValue("@AuditDate", entity.AuditDate);
                cmd.SetParameterValue("@AuditStatus", entity.AuditStatus);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return entity;
        }

        public bool ProductInfo_Update(ProductInfo_Entity entity)
        {
            bool succ = false;
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("ProductInfo_Update");
                cmd.SetParameterValue("@ProductID", entity.ProductID);
                cmd.SetParameterValue("@ProductName", entity.ProductName);
                cmd.SetParameterValue("@CategoryID", entity.CategoryID);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@UserID", entity.UserID);
                cmd.SetParameterValue("@ProductDescription", entity.ProductDescription);
                cmd.SetParameterValue("@PlaceOfOrigin", entity.PlaceOfOrigin);
                cmd.SetParameterValue("@MainKeyword", entity.MainKeyword);
                cmd.SetParameterValue("@Keywords", entity.Keywords);
                cmd.SetParameterValue("@OEMNO", entity.OEMNO);
                cmd.SetParameterValue("@CertificateIDS", entity.CertificateIDS);
                cmd.SetParameterValue("@GroupID", entity.GroupID);
                cmd.SetParameterValue("@KeyProducts", entity.KeyProducts);
                cmd.SetParameterValue("@Application", entity.Application);
                cmd.SetParameterValue("@PicImgs", entity.PicImgs);
                cmd.SetParameterValue("@IsDeleted", entity.IsDeleted);
                cmd.SetParameterValue("@CreateDate", entity.CreateDate);
                cmd.SetParameterValue("@CreateIP", entity.CreateIP);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.SetParameterValue("@UpdateIP", entity.UpdateIP);
                cmd.SetParameterValue("@AuditDate", entity.AuditDate);
                cmd.SetParameterValue("@AuditStatus", entity.AuditStatus);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

        public bool ProductInfo_Delete(System.Int32 ProductID)
        {
            bool succ = false;
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("ProductInfo_Delete");
                cmd.SetParameterValue("@ProductID", ProductID);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }
		
	}
}
